package com.aitesting.testcase;


import com.aitesting.domain.IStep;
import com.aitesting.domain.TStep;

import java.util.HashMap;
import java.util.Map;

/**
 * 填充提取数据
 */
public class StepRequestExtraction implements IStep {
    private TStep step;

    public StepRequestExtraction(TStep step) {
        this.step = step;
    }

    /**
     * 提取接口返回参数
     * @param jsonpath 参数路径
     * @param var_name 变量名称
     * @return StepRequestExtraction
     */
    public StepRequestExtraction with_jsonpath(String jsonpath, String var_name){
        /*Map<String, Object> map = new HashMap<>();
        map.put(jsonpath, var_name);*/
        this.step.getExtract().put(var_name, jsonpath);
        return this;
    }

    /**
     * 添加断言信息
     * @return RequestWithValidation对象
     */
    public StepWithValidation validate(){
        return new StepWithValidation(step);
    }

    @Override
    public TStep perform() {
        return this.step;
    }
}
